package com.service.imput;

import com.dao.Userdao;
import com.entity.User;
import com.service.UserService;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;
@Service("UserService")
//@Scope("singleton") //Bean的作用域`
public class UserServiceImp implements UserService {
    @Resource
    private Userdao userdao;

    @Override
        //添加事务Transactional,设置事务类型propagation，设置只读属性readOnly
    @Transactional(readOnly = true)
    public List<User> infort() {
        return userdao.infort();
    }

    @Override
//    @Transactional(propagation = Propagation.REQUIRED)
    public int add(User user) {
        return userdao.add(user);
    }

}
